bitkeeper revision 1.869 (40859ef9aFFaEpjd21oxJfT1ZpI7MQ)
authorach61@labyrinth.cl.cam.ac.uk <ach61@labyrinth.cl.cam.ac.uk>
Tue, 20 Apr 2004 22:06:49 +0000 (22:06 +0000)
committerach61@labyrinth.cl.cam.ac.uk <ach61@labyrinth.cl.cam.ac.uk>
Tue, 20 Apr 2004 22:06:49 +0000 (22:06 +0000)
domain = -2 for most recently created domain

xen/arch/i386/pdb-stub.c
xen/common/domain.c
xen/include/xen/sched.h

index 05e79dd31fba04669d77360504db6b2eb4234272..049f330cf69c8b62086da7183b1ade70d30ee00d 100644 (file)
@@ -344,7 +344,21 @@ pdb_process_command (char *ptr, struct pt_regs *regs, unsigned long cr3,
        {
            struct task_struct *p;
 
-           p = find_domain_by_id(pdb_ctx.domain);
+           if (pdb_ctx.domain == -2)
+           {
+               p = find_last_domain();
+           }
+           else
+           {
+               p = find_domain_by_id(pdb_ctx.domain);
+           }
+           if (p == NULL)
+           {
+               printk ("pdb error: unknown domain [0x%x]\n", pdb_ctx.domain);
+               strcpy (pdb_out_buffer, "E01");
+               pdb_ctx.domain = -1;
+               goto exit;
+           }
            if (p->mm.shadow_mode)
                pdb_ctx.ptbr = pagetable_val(p->mm.shadow_table);
            else
@@ -357,6 +371,14 @@ pdb_process_command (char *ptr, struct pt_regs *regs, unsigned long cr3,
            unsigned long domain_ptbr;
 
            p = find_domain_by_id(pdb_ctx.domain);
+           if (p == NULL)
+           {
+               printk ("pdb error: unknown domain [0x%x][0x%x]\n", 
+                       pdb_ctx.domain, pdb_ctx.process);
+               strcpy (pdb_out_buffer, "E01");
+               pdb_ctx.domain = -1;
+               goto exit;
+           }
            if (p->mm.shadow_mode)
                domain_ptbr = pagetable_val(p->mm.shadow_table);
            else
@@ -364,7 +386,7 @@ pdb_process_command (char *ptr, struct pt_regs *regs, unsigned long cr3,
            put_task_struct(p);
 
            pdb_ctx.ptbr = domain_ptbr;
-           /* pdb_ctx.ptbr = pdb_linux_pid_ptbr(domain_ptbr, pdb_ctx.process); */
+           /*pdb_ctx.ptbr=pdb_linux_pid_ptbr(domain_ptbr, pdb_ctx.process);*/
        }
 
        pdb_ctx.valid = 0;
@@ -634,6 +656,7 @@ pdb_process_command (char *ptr, struct pt_regs *regs, unsigned long cr3,
     }
     }
 
+exit:
     /* reply to the request */
     pdb_put_packet (pdb_out_buffer, ack);
 
index 053dfecef45a392c983550ca142f4acfb481d86b..87b4d19aa0db2ab5f11e5a5a8de480b456a31d4f 100644 (file)
@@ -60,6 +60,7 @@ struct task_struct *do_createdomain(domid_t dom_id, unsigned int cpu)
 
     p->domain    = dom_id;
     p->processor = cpu;
+    p->create_time = NOW();
 
     memcpy(&p->thread, &idle0_task.thread, sizeof(p->thread));
 
@@ -141,6 +142,28 @@ struct task_struct *find_domain_by_id(domid_t dom)
 }
 
 
+/* return the most recent domain created */
+struct task_struct *find_last_domain(void)
+{
+    struct task_struct *p, *plast;
+    unsigned long flags;
+
+    read_lock_irqsave(&tasklist_lock, flags);
+    plast = task_list;
+    p = plast->next_list;
+    while ( p != NULL )
+    {
+       if ( p->create_time > plast->create_time )
+           plast = p;
+        p = p->next_list;
+    }
+    get_task_struct(plast);
+    read_unlock_irqrestore(&tasklist_lock, flags);
+
+    return plast;
+}
+
+
 void kill_domain_with_errmsg(const char *err)
 {
     printk("DOM%llu FATAL ERROR: %s\n", current->domain, err);
index fcccf3fa235a694f534564a8364095a1ffaaa09c..14f4019ac1a9223a2086b42bedf9dee5f26e4ab7 100644 (file)
@@ -150,6 +150,7 @@ struct task_struct
     mm_segment_t addr_limit;
 
     char name[MAX_DOMAIN_NAME];
+    s_time_t create_time;
 
     struct thread_struct thread;
     struct task_struct *next_list, *next_hash;
@@ -239,6 +240,7 @@ extern int construct_dom0(struct task_struct *p,
 extern int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *);
 
 struct task_struct *find_domain_by_id(domid_t dom);
+struct task_struct *find_last_domain(void);
 extern void release_task(struct task_struct *);
 extern void __kill_domain(struct task_struct *p);
 extern void kill_domain(void);